<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var arr = [1,2,3,4,5,6,7,8,9,10,11,12];
    var data = [];
    for(let i =0;i<3;i++){
        var one = arr.shift();
        data.push(one);
        for (var m = 0; m<4;m++){
                var last = data[data.length - 1];
               var num = arr.indexOf(last+3)
              if(num != -1){
                  data.push(last+3)
                  arr.splice(num,1)
            }
        }
    }
</script>
</body>
</html>